3f12430a19c38286c8a911a6039c65ca8b959217,uportal-war/src/main/java/org/jasig/portal/io/xml/JaxbPortalDataHandlerService.java,JaxbPortalDataHandlerService,importData,#File#String#BatchImportOptions#,317

Before Change


	            }
	            
	            //Wait for all of the imports on of this type to complete
	            waitForFutures(importFutures, failed, failOnError, true);
	        }
	        
	        if (!dataToImport.isEmpty()) {

After Change


        final File importReport = new File(logDirectory, "data-import.txt");
        final PrintWriter reportWriter;
        try {
            reportWriter = new PrintWriter(new BufferedWriter(new FileWriter(importReport)));
        }
        catch (IOException e) {
            throw new RuntimeException("Failed to create FileWriter for: " + importReport, e);
        }
        
        
        //Convert directory to URI String to provide better logging output
    	final URI directoryUri = directory.toURI();
        final String directoryUriStr = directoryUri.toString();
		IMPORT_BASE_DIR.set(directoryUriStr);
        try {
	        //Scan the specified directory for files to import
	        logger.info("Scanning for files to Import from: {}", directory);
	        final PortalDataKeyFileProcessor fileProcessor = new PortalDataKeyFileProcessor(this.dataKeyTypes, options);
			this.directoryScanner.scanDirectoryNoResults(directory, fileFilter, fileProcessor);
	        final long resourceCount = fileProcessor.getResourceCount();
			logger.info("Found {} files to Import from: {}", resourceCount, directory);

			//See if the import should fail on error
	        final boolean failOnError = options != null ? options.isFailOnError() : true;
	        
	        //Map of files to import, grouped by type
	        final ConcurrentMap<PortalDataKey, Queue<Resource>> dataToImport = fileProcessor.getDataToImport();
	        
	        //Import the data files
	        for (final PortalDataKey portalDataKey : this.dataKeyImportOrder) {
	            final Queue<Resource> files = dataToImport.remove(portalDataKey);
	            if (files == null) {
	                continue;
	            }
	
	            final Queue<ImportFuture<?>> importFutures = new LinkedList<ImportFuture<?>>();
	            final List<FutureHolder<?>> failedFutures = new LinkedList<FutureHolder<?>>();
	            
	            final int fileCount = files.size();
	            logger.info("Importing {} files of type {}", fileCount, portalDataKey);
                reportWriter.println(portalDataKey + "," + fileCount);
	            
	            for (final Resource file : files) {
	                //Check for completed futures on every iteration, needed to fail as fast as possible on an import exception
	                final List<FutureHolder<?>> newFailed = waitForFutures(importFutures, reportWriter, logDirectory, false);
	                failedFutures.addAll(newFailed);
	                
	                final AtomicLong importTime = new AtomicLong(-1);
	                
	                //Create import task
	                Callable<Object> task = new CallableWithoutResult() {
                        @Override
                        protected void callWithoutResult() {
	                    	IMPORT_BASE_DIR.set(directoryUriStr);
	                    	importTime.set(System.nanoTime());
	                        try {
	                        	importData(file, portalDataKey);
	                        }
	                        finally {
	                            importTime.set(System.nanoTime() - importTime.get());
	                        	IMPORT_BASE_DIR.remove();
	                        }
	                    }
	                };
	                
	                //Submit the import task
	                final Future<?> importFuture = this.importExportThreadPool.submit(task);
	                
	                //Add the future for tracking
	                importFutures.offer(new ImportFuture(importFuture, file, portalDataKey, importTime));
	            }
	            
	            //Wait for all of the imports on of this type to complete
	            final List<FutureHolder<?>> newFailed = waitForFutures(importFutures, reportWriter, logDirectory, true);
                failedFutures.addAll(newFailed);
                
                if (failOnError && !failedFutures.isEmpty()) {
                    throw new RuntimeException(failedFutures.size() + " " + portalDataKey + " entities failed to import.\n\n" +